package com.dk.demo.core.service;

import com.dk.base.client.BaseClient;
import com.dk.base.common.model.DemoDTO;
import com.dk.base.proxy.DemoProxy;
import com.dk.demo.common.defs.DemoDefs;
import com.dk.shared.events.demo.DemoBusEvent;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DemoService {

    @Autowired
    BaseClient baseClient;
    @Autowired
    DemoProxy demoProxy;

    @Autowired
    private ApplicationEventPublisher eventPublisher;

    public List<DemoDTO> list() {
        return baseClient.list();

    }

    public List<DemoDTO> listProxy() {
        return demoProxy.list();
    }

    @Autowired
    private KafkaTemplate<String, String> stringKafkaTemplate;
    public Integer insert(Integer num) {
       //eventPublisher.publishEvent(DemoBusEvent.of(DemoDefs.SERVICE_NAME,num));
       stringKafkaTemplate.send("first",num.toString());
        return num;
    }


}
